package com.le.tester.leetcode;

import java.util.Arrays;

/**
 * 描述：非空数组中只出现一次的数字
 */
public class SingleNumber {
    public int singleNumber(int[] nums) {

        Arrays.sort(nums);
        int length = nums.length;
        //第一个为基准
        for (int i = 1; i < length; i++) {
            if (nums[i - 1] == nums[i]) {
                nums[i - 1] = -99;
                nums[i] = -99;
            }
        }
        System.out.println(Arrays.toString(nums));
        int[] result = Arrays.stream(nums).filter(o -> o != -99).toArray();
        return result[0];
    }

    public static void main(String[] args) {
        new SingleNumber().singleNumber(new int[]{1, 0, 1});
    }
}
